package com.lemon.smartsafetynew.ui.activity.contact;

import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.lemon.smartsafety.R;
import com.lemon.smartsafetynew.ui.activity.base.BaseFragmentActivity;
import com.lemon.smartsafetynew.entity.event.common.ViewEvent;
import com.lemon.smartsafetynew.ui.fragment.contact.DepartmentListFragment;
import com.lemon.smartsafetynew.util.constants.KeyConstants;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

/**
 * 部门列表
 * Created by Andrew on 2017/9/11.
 */

public class DepartmentListActivity extends BaseFragmentActivity {

    private static String tag = "";

    @Override
    protected void getBundleArgs() {
        super.getBundleArgs();

        Bundle bundle = getIntent().getExtras();
        if (bundle != null) {
            if (bundle.containsKey(KeyConstants.KEY_TAG)) {
                tag = bundle.getString(KeyConstants.KEY_TAG);
            }
        }

    }

    @Override
    public Fragment getFragment() {
        return DepartmentListFragment.newInstance(tag);
    }

    @Override
    protected void initTitle() {
        this.setBarTitle(getString(R.string.contact_department_str));
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onViewEvent(ViewEvent event) {

        if(DepartmentListFragment.class.getName().equals(event.getTag())) {
            callFinish();
        }

    }
}
